package ic.ast;
import ic.symbols.*;

/**
 * Abstract AST node base class.
 */
public abstract class Node {

    private SymbolTable enclosingScope;
	private int line;
    private int typeTableID;

	/**
	 * Double dispatch method, to allow a visitor to visit a specific subclass.
	 * 
	 * @param visitor
	 *            The visitor.
	 * @return A value propagated by the visitor.
	 */
	public abstract Object accept(Visitor visitor) throws Exception;

	/**
	 * Constructs an AST node corresponding to a line number in the original
	 * code. Used by subclasses.
	 * 
	 * @param line
	 *            The line number.
	 */
	protected Node(int line) {
		this.line = line;
	}

    /**
     * @return symbol table
     */
    public SymbolTable getEnclosingScope() {
        return enclosingScope;
    }

    /**
     * Sets symbol table for the relevant scope
     * @param enclosingScope scope
     */
    public void setEnclosingScope(SymbolTable enclosingScope) {
        this.enclosingScope = enclosingScope;
    }

    /**
     * @return line
     */
	public int getLine() {
		return line;
	}

    public int getTypeTableID() {
        return typeTableID;
    }

    public void setTypeTableID(int typeTableID) {
        this.typeTableID = typeTableID;
    }
}
